package com.qtt.app.mapper;

import com.qtt.app.entity.AppCourse;
import com.qtt.app.entity.AppCourseWithBLOBs;
import com.qtt.app.entity.ReturnInfo.ReturnTopCourses;
import com.qtt.app.entity.ReturnInfo.ReturnTotalCourseInfo;
import com.qtt.app.entity.ReturnInfo.StudyCourse.NoticeOffline;
import com.qtt.app.entity.ReturnInfo.StudyCourse.ReturnMyOnlineCourse;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository

public interface AppCourseMapper {
    int deleteByPrimaryKey(Integer appcourseId);

    int insert(AppCourseWithBLOBs record);

    int insertSelective(AppCourseWithBLOBs record);

    AppCourseWithBLOBs selectByPrimaryKey(Integer appcourseId);

    int updateByPrimaryKeySelective(AppCourseWithBLOBs record);

    int updateByPrimaryKeyWithBLOBs(AppCourseWithBLOBs record);

    int updateByPrimaryKey(AppCourse record);

    List<AppCourse> getAll();

    List<AppCourse> getInstitutionCourse(Integer institutionId);

    @Select("SELECT appcourse_id FROM app_course ORDER BY appcourse_id DESC LIMIT 1")
    int getLastId();

    List<AppCourse> getCoursesByType(@Param("courseType") String courseType);

    @Select("SELECT institution_id FROM app_course WHERE general_id = #{generalId}")
    Integer getInstitutionIdByCourse(@Param("generalId") String generalId);


    List<ReturnTotalCourseInfo> getOnlineCourses();

    List<ReturnTotalCourseInfo> getOfflineCourses();

    @Select("SELECT course_type FROM app_course WHERE course_id = #{courseId}")
    String getTypeByCourseId(@Param("courseId") String courseId);

    @Select("SELECT appcourse_id FROM app_course WHERE general_id = #{generalId}")
    Integer getIdByGeneralId(@Param("generalId") String generalId);

    List<ReturnTotalCourseInfo> getOnlineCoursesByUserId(Long userId);

    List<ReturnTotalCourseInfo> getOfflineCoursesByUserId(Long userId);

    List<ReturnMyOnlineCourse> getMyOnlineCoursesByUserId(@Param("userId") Long userId);

    List<ReturnMyOnlineCourse> getMyOfflineCoursesByUserId(@Param("userId") Long userId);

    List<ReturnMyOnlineCourse> getMyCourseAll(@Param("userId") Long userId);

    List<ReturnTopCourses> getTopCourses();

    NoticeOffline getOfflineCourseNotice(@Param("generalId") String generalId);
}